#ifndef IAPUDP_H
#define IAPUDP_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

int32_t udp_read(uint8_t * pdata, int32_t len);

int32_t udp_write(uint8_t * pdata, int32_t len);

#ifdef __cplusplus
}
#endif

#include <QUdpSocket>
#include <QString>
#include <QByteArray>

class IapUdp
{
public:
    IapUdp();
    bool BindLocalAddr(QHostAddress ip, quint16 port);
    void SetSendAddr(QHostAddress ip, quint16 port);
    qint64 Read(char * data, qint64 maxSize, QHostAddress * ip, quint16 * port, int32_t to);
    qint64 Write(QByteArray data);
    void Close();
    void Refresh();
private:
    QUdpSocket __udpsock;
    QHostAddress __localIp;
    quint16      __localPort;
    QHostAddress __sendIp;
    quint16      __sendPort;
};

#endif // IAPUDP_H
